Connectivity Software User's Guide and Reference
Examples - OPC Classic Specialized - Kepware KEPServerEX - Write item value

.NET

// This KEPServerEX example shows how to write a value into a single item.
//
// Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.Specialized
{
    partial class Kepware_KEPServerEX
    {
        public static void WriteItemValue()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            try
            {
                client.WriteItemValue(
                    "", "Kepware.KEPServerEX.V6", 
                    "Data Type Examples.16 Bit Device.K Registers.Long1", 12345);
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }
            Console.WriteLine("Success");
        }
    }
}